package com.winshare.saleAssistant.controller;

import com.winshare.saleAssistant.domain.dto.req.*;
import com.winshare.saleAssistant.service.ArticleModuleService;
import com.winshare.saleAssistant.util.LogicResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sys/articleModule")
@CrossOrigin
@Api(value = "文章管理->栏目管理", description = "文章管理->栏目管理")
public class ArticleModuleController {

    private final ArticleModuleService articleModuleService;

    public ArticleModuleController(ArticleModuleService articleModuleService) {
        this.articleModuleService = articleModuleService;
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增栏目接口",notes = "新增栏目接口")
    public LogicResponse save(@RequestBody @Validated ArticleModuleCreateDTO articleModuleCreateDTO) {
        articleModuleService.save(articleModuleCreateDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改栏目接口",notes = "修改栏目接口")
    public LogicResponse update(@RequestBody @Validated ArticleModuleUpdateDTO articleModuleUpdateDTO) {
        articleModuleService.update(articleModuleUpdateDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除栏目接口",notes = "删除栏目接口")
    public LogicResponse delete(@RequestBody @Validated ArticleModuleDeleteDTO articleModuleDeleteDTO) {
        articleModuleService.delete(articleModuleDeleteDTO);
        return LogicResponse.success("success");
    }

    @PostMapping("/list")
    @ApiOperation(value = "查询文章栏目列表接口",notes = "查询文章栏目列表接口")
    public LogicResponse queryArticleModulePage(@RequestBody @Validated ArticleModuleQueryDTO articleModuleQueryDTO) {
        return LogicResponse.success(articleModuleService.getArticleModuleList(articleModuleQueryDTO));
    }

    @PostMapping("detail")
    @ApiOperation(value = "获取单个文章栏目详情")
    public LogicResponse getArticleModuleDetail(@RequestBody @Validated BaseIdDTO baseIdDTO) {
        return LogicResponse.success(articleModuleService.getArticleModuleDetail(baseIdDTO));
    }
}
